<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('考试记录列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>试卷标题：</label>
                            <input type="text" name="title"/>
                        </li>
                        <li>
                            <label>课程名称：</label>
                            <input type="text" name="courseName"/>
                        </li>
                        <li>
                            <label>班级名称：</label>
                            <input type="text" name="deptName"/>
                        </li>
                        <li>
                            <label>考生姓名：</label>
                            <input type="text" name="username"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select name="status" th:with="type=${@dict.getType('exam_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script th:inline="javascript">
    var examFlag = [[${@permission.hasPermi('system:sysStudentExam:exam')}]];
    var statusDatas = [[${@dict.getType('exam_status')}]];
    var prefix = ctx + "system/sysStudentExam";

    $(function() {
        var options = {
            url: prefix + "/studentList",
            examUrl: prefix + "/exam/{id}",
            modalName: "考试记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'title',
                    title: '试卷标题'
                },
                {
                    field: 'courseName',
                    title: '课程名称'
                },
                {
                    field: 'deptName',
                    title: '班级名称'
                },
                {
                    field: 'startTime',
                    title: '作答时间',
                    formatter: function(value) {
                        return value ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '';
                    }
                },
                {
                    field: 'endTime',
                    title: '提交时间',
                    formatter: function(value) {
                        return value ? moment(value).format('YYYY-MM-DD HH:mm:ss') : '';
                    }
                },
                {
                    field: 'duration',
                    title: '考试时间'
                },
                {
                    field: 'score',
                    title: '考试得分'
                },
                {
                    field: 'username',
                    title: '考生姓名'
                },
                {
                    field: 'grade',
                    title: '满分'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status === 'WAITING_FOR_THE_EXAM') {
                            actions.push('<a class="btn btn-success btn-xs ' + examFlag + '" href="javascript:void(0)" onclick="$.operate.exam(\'' + row.id + '\')"><i class="fa fa-detail"></i>开始考试</a> ');
                        }
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>